import {
  getDictionaryList,
  getOrgAllList,
  getRoleList,
  getUnitData,
  getUserAllList,
  getprojectList
} from '@/views/science/api/common'

const technologyStrength: any = {
  namespaced: true,
  state: {
    rowId: '',
    addFlag:null,

    roleList: [], //角色列表
    userAllList: [], //全部人员
    orgAllList: [], //全部机构单位

    sexList: [], //性别
    minzuList: [],//民族
    politicsList: [],//政治面貌

    unitSelet: [], //登录人下单位信息
    usersSelet: [], // 登录人下人员信息

    researchSelect: [], //研究方向
    gdconstructSelect: [], //高端研发平台-建设方式
    stateSelect: [], //平台状态
    ptRoleList: [], //成员角色
    fileTypeList: [], //文件类型
    gdlevelSelect: [], //高端研发平台-平台级别
    gjconstructSelect: [], //国际科技合作基地-建设方式
    jdLevelSelect: [], //基地级别
    kjlevelSelect: [], //科技转移转化平台-平台级别
    typeSelect: [], //专业级别
    kjtypeSelect: [], //科技转移转化平台-专业类别

    levelSelect: [], //平台级别
    xtcxTypeSelect: [], // 协同创新平台-专业级别
    classSelect: [], //平台类别
    zyClassSelect: [], //专业类别
    ptRoleSelect: [], //平台成员的平台角色
    projectStateSelect: [], // 项目状态
    projectSelect: [], // 项目来源


    cooperateList: [], //合作方式

    form: {
      name: '',
      abbreviation: '',
      headBy: '',
      headName: '',
      phone: '',
      reDirection: '',
      reField: '',
      reFieldName: '',
      conUnit: '',
      conUnitName: '',
      level: '',
      levelName: '',
      type: '',
      typeName: '',
      rdDept: '',
      rdDeptName: '',
      rdDate: '',
      evCycle: '',
      way: '',
      wayName: '',
      plaStatus: '',
      plaStatusName: '',
      plaUnit: '',
      plaUnitName: '',

      jobNums: '',
      faxes: '',
      wbUrl: '',
      drNums: '',
      inteNums: '',

      cjUnit: '', //内部共建单位
      cjUnitName: '',
      cjUnit2: '', //外部共建单位

      deptIntroduction: '',

      sitPlan: '',
      sitStandard: '',
      sitAwards: '',

      id: '',
    },

    innovateForm: {
      id: '',
      name: '',
      abbreviation: '',
      code: '',
      unitName: '',
      unitId: '',
      manager: '',
      managerId: '',
      managerTel: '',
      level: '',
      levelId: '',
      subject: '',
      subjectId: '',
      construct: '',
      constructId: '',
      identifyOrg: '',
      identifyDate: '',
      briefIntroduction: '',
    },

    cooperationForm: {
      id: '',
      name: '',
      code: '',
      buildUnit: '',
      buildUnitId: '',
      manager: '',
      managerId: '',
      managerTel: '',
      level: '',
      levelId: '',
      subject: '',
      subjectId: '',
      construct: '',
      constructId: '',
      identifyOrg: '',
      identifyDate: '',
      baseStatus: '',
      baseStatusId: '',
      briefIntroduction: '',
    },

    transferForm: {
      id: '',
      name: '',
      code: '',
      buildUnit: '',
      buildUnitId: '',
      manager: '',
      managerId: '',
      managerTel: '',
      level: '',
      levelId: '',
      subjectClass: '',
      subjectClassId: '',
      identifyOrg: '',
      identifyDate: '',
      baseStatus: '',
      baseStatusId: '',
      briefIntroduction: '',
    },

    gjhProjectLevel: [], //项目级别类别
    gjhLevelSelect: [], // 国际化交流合作-级别-类别
    gjhInteractSelect: [], // 合作方式
    gjhStatueSelect: [], // 项目状态
    gjhInterflowType: [], // 交流类别
    gjhMeetingType: [], //会议类别
    gjhShapeSelect: [], // 参与形式

    technologyProjectsInfo: {
      id: '',
      name: '',
      cooperationMode: '',
      cooperationModeId: '',
      buildUnit: '',
      buildUnitId: '',
      chargePerson: '',
      chargePersonId: '',
      projectLevel: '',
      projectLevelId: '',
      projectClass: '',
      projectClassId: '',
      totalBudget: '',
      approveExternalFund: '',
      partnerContactUnit: '',
      partnerContactPerson: '',
      partnerContactTel: '',
      projectState: '',
      projectStateId: '',
      approvalDate: '',
      shortIntroduction: '',
      expectedAchieve: '',
      remark: '',
    },

    talentInfo: {
      id: '',
      userName: '',
      userId: '',
      sex: '',
      unit: '',
      unitId: '',
      communicateClass: '',
      communicateClassId: '',
      communicateDate: '',
      communicateStyle: '',
      communicateStyleId: '',
      detailInfo: '',
      remark: '',
    },

    meetingInfo: {
      id: '',
      name: '',
      mettingTime: '',
      className: '',
      classId: '',
      joinMethod: '',
      joinMethodId: '',
      unitName: '',
      unitId: '',
      contractUser: '',
      contractUserId: '',
      contractMethod: '',
      reportTitle: '',
      joinPersons: '',
      joinPersonIds: '',
      remark: '',
    },


    KJSL_DECLARATION_TYPE: [],//申报类型
    KJSL_APPLYING_FOR_AWARDS1: [], //申报奖项
    KJSL_AWARD_CATEGORY: [], // 获奖类别
    KJSL_PROJECT_LEVEL: [], //科技奖励项目级别

    KHGL_KJSL_HJJB: [],

    achievementINFO: {
      id: '',
      awardApplyName: '', //申报奖项
      awardApplyId: '',
      applyClass: '', //申报类型
      applyClassId: '',
      relateId: "",
      relateName: "",
      relatetype: "",
      relatetypeName: '',
      projectId: '',
      applyUnitName: '', //申报单位
      applyUnitId: '',
      applyUser: '',
      applyUserId: '', //申报人
      applyTime: '', //申报时间
      projectName: '', //项目名称
      projectNo: '', //项目编号
      bonus: '', //项目编号
      shortIntroduction: '', //简介
      unitRemark: '', //单位备注
      projectYear: '', //年份
      remark1: '', //备注
    },

    fbxxINFO: {
      projectId: "",
      projectname: "",
      projectsource: "",
      classid: "",
      classname: "",
      competitionclassid: "",
      competitionclass: "",
      joinpersonids: "",
      joinpersons: "",
      starttime: "",
      endtime: "",
      incentivestandardid: "",
      incentivestandard: "",
      awardlevelid: "",
      awardlevel: "",
      awardwinningid: "",
      awardwinning: "",
      awardwinninglevelid: "",
      awardwinninglevel: "",
      awardtime: "",
      issuingunitid: "",
      issuingunit: "",
      grouprankingid: "",
      groupranking: "",
      participantid: "",
      participant: "",
      participantunit: "",
      participantjs: "",
      code:"",
      name:'',
    },

    award_talentINFO: {
      id: '',
      cname: '',
      username: '',
      userId: '1',
      sex: '',
      sexName: '',
      mingzu: '',
      mingzuName: '',
      birth: '',
      political: '',
      politicalName: '',
      professional: '',
      administrative: '',
      highesteducation: '',
      highestdegree: '',
      speciality: '',
      technical: '',
      research: '',
      recommendUnitId: '',
      recommendUnit: '',
      unitContactId: '',
      unitContact: '',
      unitContactRel: '',
      unitContactEmail: '',
      chargeId: '',
      chargeName: '',
      mainKpsResult: '',
    },

    groupINFO: {
      id: '',
      recommendUnitId: "",
      recommendUnit: "",
      teamName: "",
      teamChargeId: "",
      teamCharge: "",
      unitContactId: "",
      unitContact: "",
      unitContactRel: "",
      unitContactEmail: "",
      mainCompletePersonIds: "",
      mainCompletePersons: "",
      shortIntroduction: "",
    }
  },
  mutations: {
    emptygroupINFO(state: any) {
      Object.keys(state.groupINFO).forEach((key) => {
        state.groupINFO[key] = ''
      })
    },

    getgroupINFO(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.groupINFO
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      console.log(list)
      state.groupINFO = { ...list }
    },

    emptyaward_talentINFO(state: any) {
      Object.keys(state.award_talentINFO).forEach((key) => {
        state.award_talentINFO[key] = ''
      })
    },

    getaward_talentINFO(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.award_talentINFO
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.award_talentINFO = { ...list }
    },

    emptyachievementINFO(state: any) {
      Object.keys(state.achievementINFO).forEach((key) => {
        state.achievementINFO[key] = ''
      })
    },

    getachievementINFO(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.achievementINFO
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.achievementINFO = { ...list }
    },

    getfbxxINFO(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.fbxxINFO
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.fbxxINFO = { ...list }
    },

    getRowId(state: any, id) {
      state.rowId = id
    },

    getAddFlag(state: any, num) {
      state.addFlag = num
    },

    emptyForm(state: any) {
      const list = state.form
      for (const key in list) {
        list[key] = ''
      }
      state.form = { ...list }
    },

    emptyinnovateForm(state: any) {
      Object.keys(state.innovateForm).forEach((key) => {
        state.innovateForm[key] = ''
      })
    },

    emptycooperationForm(state: any) {
      Object.keys(state.cooperationForm).forEach((key) => {
        state.cooperationForm[key] = ''
      })
    },

    emptytransferForm(state: any) {
      Object.keys(state.transferForm).forEach((key) => {
        state.transferForm[key] = ''
      })
    },

    emptytechnologyProjectsInfo(state: any) {
      Object.keys(state.technologyProjectsInfo).forEach((key) => {
        state.technologyProjectsInfo[key] = ''
      })
    },

    emptytalentInfo(state: any) {
      Object.keys(state.talentInfo).forEach((key) => {
        state.talentInfo[key] = ''
      })
    },

    emptymeetingInfo(state: any) {
      Object.keys(state.meetingInfo).forEach((key) => {
        state.meetingInfo[key] = ''
      })
    },

    getForm(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.form
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.form = { ...list }
    },

    getinnovateForm(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.innovateForm
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.innovateForm = { ...list }
    },

    getcooperationForm(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.cooperationForm
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.cooperationForm = { ...list }
    },

    gettransferForm(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.transferForm
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.transferForm = { ...list }
    },

    gettechnologyProjectsInfo(state: any, data) {
      // alert("获取2")
      const arr1 = Object.keys(data)
      const list = state.technologyProjectsInfo
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.technologyProjectsInfo = { ...list }
    },

    gettalentInfo(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.talentInfo
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) {
          list[key] = data[key]
        }
      }
      state.talentInfo = { ...list }
    },

    getmeetingInfo(state: any, data) {
      const arr1 = Object.keys(data)
      const list = state.meetingInfo
      for (const key in list) {
        if (arr1.indexOf(key) !== -1) list[key] = data[key]
        else list[key] = null
      }
      state.meetingInfo = { ...list }
    },

    saveDictionaryList(state: any, listData) {

      state.gdlevelSelect = listData.KJSL_GD_LEVEL
      state.researchSelect = listData.KJSL_RESEARCH_FIELD
      state.gdconstructSelect = listData.KJSL_HPLAT_CONSTRUCTION_METHOD
      state.stateSelect = listData.KJSL_PLATFORM_STATUS
      state.ptRoleList = listData.KJSL_MEMBER_ROLE
      state.fileTypeList = listData.KJSL_FILE_TYPE
      state.levelSelect = listData.KJSL_INNOVATE_PLATFORM_LEVEL
      state.xtcxTypeSelect = listData.KJSL_INNOVATE_ZY_LEVEL
      state.gjconstructSelect = listData.KJSL_CONSTRUCTION_METHOD
      console.log('state.gjconstructSelect',state.gjconstructSelect);
      state.jdLevelSelect = listData.KJSL_BASE_LEVEL
      state.kjlevelSelect = listData.KJSL_PLATFORM_LEVEL
      state.typeSelect = listData.KJSL_PROFESSIONAL_LEVEL
      state.kjtypeSelect = listData.KJSL_ZH_TYPE

      // state.gjhProjectLevel = listData.KJSL_PROJECT_LEVEL_CATEGORY//之前取用得的字典
      state.gjhProjectLevel = listData.KJSL_GD_LEVEL2
      state.gjhLevelSelect = listData.KJSL_GJ_LEVEL
      state.gjhInteractSelect = listData.KJSL_COOPERATION_METHODS
      state.gjhStatueSelect = listData.KJSL_PROJECT_STATUS
      state.gjhInterflowType = listData.KJSL_COMMUNICATION_CATEGORY
      state.gjhMeetingType = listData.KJSL_MEETING_CATEGORY
      state.gjhShapeSelect = listData.KJSL_FORM_OF_PARTICIPATION1
      state.sexList = listData.SEX
      state.minzuList = listData.NATIONALITY
      state.politicsList = listData.KJSL_POLITICAL_STATUS

      state.KJSL_DECLARATION_TYPE = listData.KJSL_DECLARATION_TYPE
      state.KJSL_APPLYING_FOR_AWARDS1 = listData.KJSL_APPLYING_FOR_AWARDS1
      state.KJSL_AWARD_CATEGORY = listData.KJSL_AWARD_CATEGORY
      state.KHGL_KJSL_HJJB = listData.KHGL_KJSL_HJJB
      state.KJSL_PROJECT_LEVEL = listData.KJSL_PROJECT_LEVEL
    },

    saveRoleList(state: any, listData) {
      state.roleList = listData
    },

    saveUserAllList(state: any, listData) {
      state.userAllList = listData
    },

    saveOrgAllList(state: any, listData) {
      state.orgAllList = listData
    },

    saveUnitList(state: any, listData) {
      state.unitSelet = listData
    },

    saveProjectList(state: any, listData) {
      state.projectSelect = listData
    },
  },
  actions: {
    // 获取单位信息
    async getUnit({ commit, state }: any) {
      const rst = await getUnitData()
      console.log(getUnitData)
      const data = rst.data.data
      commit('saveUnitList', { ...state.unitSelet, ...data })
    },
    // 获取人员信息
    // async getUsers({ commit, state }: any) {
    //   const rst = await getPersonnelData()
    //   const data = rst.data.data
    //   commit('saveUsersList', { ...state.usersSelet, ...data })
    // },

    // 根据字典分类code集合获取字典树
    async getDictionaryList({ commit, state }: any, params) {
      const a = params
      const rst = await getDictionaryList(a)
      // const rst = await getDictByCodeList(a)
      const data = rst.data.data
      commit('saveDictionaryList', { ...data })
    },

    async getProjectList({ commit, state }: any) {
      const rst = await getprojectList()
      const data = rst.data.data
      commit('saveProjectList', { ...data })
    },

    // 获取角色列表
    async getRoleList({ commit, state }: any) {
      const rst = await getRoleList()
      const data = rst.data.data
      commit('saveRoleList', { ...state.roleList, ...data })
    },

    //获取全部人员
    async getUserAllList({ commit, state }: any) {
      const rst = await getUserAllList()
      const data = rst.data.data
      console.log(data)
      commit('saveUserAllList', { ...state.userAllList, ...data })
    },

    //获取全部机构单位
    async getOrgAllList({ commit, state }: any) {
      const rst = await getOrgAllList()
      const data = rst.data.data
      console.log('rst=>', rst)
      commit('saveOrgAllList', [...state.orgAllList, ...data])
    },
  },
}

export default technologyStrength
